package hlhj.fhp.supreme.activitys

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebViewClient
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response
import hlhj.fhp.supreme.BaseAty
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.javabean.TextDetailBena
import hlhj.fhp.supreme.network.Urls
import hlhj.fhp.supreme.utils.JsonCallBack
import kotlinx.android.synthetic.main.activity_text_detail_aty.*

class TextDetailAty : BaseAty() {
    override fun getContentId(): Int {
        return R.layout.activity_text_detail_aty
    }


    override fun initView() {
        webView.settings.javaScriptEnabled=true
        webView.webViewClient=object :WebViewClient(){}
        webView.webChromeClient=object :WebChromeClient(){}

        OkGo.post<TextDetailBena>(Urls.BaseUrl+Urls.TEXT_DETAIL)
                .params("id",intent.getStringExtra("id"))
                .execute(object :JsonCallBack<TextDetailBena>(this@TextDetailAty){
                    override fun onSuccess(response: Response<TextDetailBena>?) {
                        val bena = response?.body()
                        if (bena!!.code==1){
                            webView.loadDataWithBaseURL(null,bena?.data.post_content,"text/html", "utf-8", null)
                        }
                    }
                })
    }

    override fun initListener() {
        btExit.setOnClickListener {
            finish()
        }


    }
}
